package com.order.feign;

import com.common.domain.pojo.Result;
import com.common.feign.OpenFeignRequestPrefix;
import com.order.domain.dto.OrderPaymentDto;
import com.order.domain.dto.OrderRefundDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient("eselect-payment-service")
public interface PaymentFeignClient {

    @PostMapping(OpenFeignRequestPrefix.PAYMENT_SERVICE)
    Result<String> initiatePayment(@RequestBody OrderPaymentDto order);

    @GetMapping(OpenFeignRequestPrefix.PAYMENT_SERVICE + "/query")
    Result<Boolean> queryPaymentResult(@RequestParam("orderNo") String orderNo);

    // 取消订单
    @PostMapping(OpenFeignRequestPrefix.PAYMENT_SERVICE + "/cancel")
    Result<Boolean> cancel(@RequestParam("orderNo") String orderNo);

    // 退款
    @PostMapping(OpenFeignRequestPrefix.PAYMENT_SERVICE + "/refund")
    Result<Boolean> refund(@RequestBody OrderRefundDto order);

    // 查询退款结果
    @GetMapping(OpenFeignRequestPrefix.PAYMENT_SERVICE + "/refund/query/status")
    Result<Byte> queryRefundResult(@RequestParam("orderNo") String orderNo);

    // 支付成功
    @PostMapping(OpenFeignRequestPrefix.PAYMENT_SERVICE + "/success")
    Result<Boolean> paymentSuccess(@RequestParam("orderNo") String orderNo);

}
